package com.example.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Pet;
import com.example.demo.mapper.PetMapper;
import com.example.demo.service.IPetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 宠物表 服务实现类
 * </p>
 *
 * @author Mr.we
 * @since 2024-06-04
 */
@Service
public class PetServiceImpl extends ServiceImpl<PetMapper, Pet> implements IPetService {
    @Autowired
    private PetMapper petMapper;
    @Override
    public boolean addPet(Pet p) {
        if(petMapper.addPet(p)==1){
            return true;
        }
        return false;
    }

    @Override
    public Pet findPetById(Integer petId) {
        return petMapper.findPetById(petId);
    }

    @Override
    public List<Pet> findPetByUserId(Integer userId) {
        return petMapper.findPetByUserId(userId);
    }

    @Override
    public List<Pet> findAll() {
        return petMapper.findAll();
    }

    @Override
    public int deletePetById(Integer petId) {
        //根据petId删除宠物信息

        return petMapper.deletePetById(petId);
    }

}
